package com.sbs.gaoxinqutoilet.fragment;

import android.os.Bundle;
import android.os.Handler;
import android.text.TextUtils;
import android.util.Log;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.inputmethod.EditorInfo;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.TextView;
import android.widget.Toast;

import androidx.annotation.IdRes;
import androidx.annotation.Nullable;
import androidx.appcompat.widget.ListPopupWindow;
import androidx.appcompat.widget.Toolbar;
import androidx.core.view.GravityCompat;
import androidx.drawerlayout.widget.DrawerLayout;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.google.gson.reflect.TypeToken;
import com.lcodecore.tkrefreshlayout.RefreshListenerAdapter;
import com.lcodecore.tkrefreshlayout.TwinklingRefreshLayout;
import com.lcodecore.tkrefreshlayout.footer.LoadingView;
import com.lcodecore.tkrefreshlayout.header.SinaRefreshView;
import com.lvfq.pickerview.TimePickerView;
import com.sbs.gaoxinqutoilet.R;
import com.sbs.gaoxinqutoilet.adapter.ToiletCheckRvAdapter;
import com.sbs.gaoxinqutoilet.base.BaseBackFragment;
import com.sbs.gaoxinqutoilet.entity.CheckItemEntity;
import com.sbs.gaoxinqutoilet.entity.CountyEntity;
import com.sbs.gaoxinqutoilet.entity.HomeMenuEntity;
import com.sbs.gaoxinqutoilet.entity.MessageEvent;
import com.sbs.gaoxinqutoilet.entity.UserEntity;
import com.sbs.gaoxinqutoilet.eventbus.EventCenter;
import com.sbs.gaoxinqutoilet.eventbus.StartNewFragmentEvent;
import com.sbs.gaoxinqutoilet.http.HttpApis;
import com.sbs.gaoxinqutoilet.http.Request;
import com.sbs.gaoxinqutoilet.interfaces.Constant;
import com.sbs.gaoxinqutoilet.interfaces.Constants;
import com.sbs.gaoxinqutoilet.interfaces.ContyPopuListener;
import com.sbs.gaoxinqutoilet.interfaces.EventConstant;
import com.sbs.gaoxinqutoilet.interfaces.PopuClickListener;
import com.sbs.gaoxinqutoilet.utils.GsonTools;
import com.sbs.gaoxinqutoilet.utils.HttpUtils;
import com.sbs.gaoxinqutoilet.utils.JsonUtil;
import com.sbs.gaoxinqutoilet.utils.LogUtils;
import com.sbs.gaoxinqutoilet.utils.NetworkUtils;
import com.sbs.gaoxinqutoilet.utils.SPUtil;
import com.sbs.gaoxinqutoilet.utils.TimeUtils;
import com.sbs.gaoxinqutoilet.utils.UtilPop;
import com.sbs.gaoxinqutoilet.utils.appinstallerutils.ConstUtils;
import com.sbs.gaoxinqutoilet.view.MyDFButton;
import com.zhy.autolayout.AutoFrameLayout;
import com.zhy.autolayout.AutoLinearLayout;
import com.zhy.autolayout.AutoRelativeLayout;
import com.zhy.http.okhttp.OkHttpUtils;

import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;

import java.lang.reflect.Type;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import butterknife.Unbinder;

/**
 * Created by 聪明一只哈 on 2018/6/2.
 * Time: 2018/6/2  9:54
 */

public class ToiletBuildCheckFragment extends BaseBackFragment implements RadioGroup.OnCheckedChangeListener {

    @BindView(R.id.toolbar_back)
    ImageView toolbarBack;
    @BindView(R.id.toolbar_title)
    TextView toolbarTitle;
    @BindView(R.id.toolbar_iv_menu)
    ImageView toolbarIvMenu;
    @BindView(R.id.toolbar_tv_menu)
    TextView toolbarTvMenu;
    @BindView(R.id.toolbar_rl_menu)
    AutoRelativeLayout toolbarRlMenu;
    @BindView(R.id.toolbar)
    Toolbar toolbar;

    @BindView(R.id.bt_buildcheck_filter)
    MyDFButton btBuildcheckFilter;
    @BindView(R.id.buildcheck_rv)
    RecyclerView buildcheckRv;
    @BindView(R.id.buildcheck_trefresh)
    TwinklingRefreshLayout buildcheckTrefresh;



    @BindView(R.id.et_check_hum)
    EditText etCheckHum;
    @BindView(R.id.bt_check_huming)
    Button btCheckHuming;


    @BindView(R.id.check_et_address)
    EditText checkEtAddress;
    @BindView(R.id.check_et_doorname)
    EditText checkEtDoorname;
    @BindView(R.id.check_et_Iidnumber)
    EditText checkEtIidnumber;
    @BindView(R.id.check_et_number)
    EditText checkEtNumber;
    @BindView(R.id.check_et_year_bg)
    TextView checkEtYearBg;
    @BindView(R.id.check_et_year_end)
    TextView checkEtYearEnd;
    @BindView(R.id.check_tv_typeone)
    TextView checkTvTypeone;
    @BindView(R.id.check_tv_typetwo)
    TextView checkTvTypetwo;
    @BindView(R.id.check_tv_typethree)
    TextView checkTvTypethree;
    @BindView(R.id.check_tv_typefour)
    TextView checkTvTypefour;
    @BindView(R.id.check_tv_typefive)
    TextView checkTvTypefive;
    @BindView(R.id.check_tv_typesix)
    TextView checkTvTypesix;
    @BindView(R.id.check_tv_typeseven)
    TextView checkTvTypeseven;
    @BindView(R.id.acceptcheck_tv_typeeight)
    TextView acceptcheckTvTypeeight;
    @BindView(R.id.check_rb_pass)
    RadioButton checkRbPass;
    @BindView(R.id.check_rb_fail)
    RadioButton checkRbFail;
    @BindView(R.id.check_rG_result)
    RadioGroup check_RG;
    @BindView(R.id.check_reset)
    Button checkReset;
    @BindView(R.id.check_done)
    Button checkDone;
    @BindView(R.id.buildcheck_drawlayout)
    DrawerLayout buildcheckDrawlayout;
    Unbinder unbinder;
    @BindView(R.id.buildcheck_fl)
    AutoFrameLayout buildcheckFl;
    @BindView(R.id.check_rb_level_city)
    RadioButton checkRbLevelCity;
    @BindView(R.id.check_rb_level_conty)
    RadioButton checkRbLevelConty;
    @BindView(R.id.check_rG_level)
    RadioGroup checkRGLevel;
    @BindView(R.id.all_sliding_licate_check)
    AutoLinearLayout allSlidingLicateCheck;
    @BindView(R.id.check_address_conty)
    TextView checkAddressConty;
    @BindView(R.id.check_address_town)
    TextView checkAddressTown;
    @BindView(R.id.toilet_check_statyear)
    TextView toiletCheckStatyear;
    @BindView(R.id.check_address_village)
    TextView checkAddressVillage;
    @BindView(R.id.tv_check_huce_count)
    TextView tvCheckHuceCount;
//    @BindView(R.id.bt_check_top)
//    Button btCheckTop;
    private ListPopupWindow checkorderPopupWindow;

    //传过来的改造检查数据  存储在Bundle中
    private static final String CHECK_BEAN = "check_bean";

    private List<String> namelist = new ArrayList<>();


    //侧滑菜单的view,所添加进的集合
    private List<View> viewchecklist;
    //Rv一次性加载多少个条目,先写在这里,设为5条
    private int pageSize = 5;
    //页数
    private int index;
    //列表数据的集合
    private ArrayList<CheckItemEntity.DataBean> buyItemList;
    private ToiletCheckRvAdapter applyRvAdapter;

    private View emptyView;
    private View errorView;
    private View footView;
    private HomeMenuEntity homemenu_check;
    private CheckItemRequest checkitemRequest;

    //筛选条件
    private Map<String, String>  conditionmap = new HashMap<>();
    //任务年份
    List<String> buildstateyearlist = new ArrayList<>();

    //改造类型
    private List<String> typelist;
    private ContyRequest cavRequest;
    private TwonRequest twonRequest;
    private VillageRequest villageRequest;
    private ListPopupWindow checkcontyPW;
    private ListPopupWindow checktwonPW;
    private Button btCheckTop;
    private String token_data;
    private ListPopupWindow buildstatyearPopupWindow;

    public static ToiletBuildCheckFragment newInstance(HomeMenuEntity homeMenuEntity) {
        Bundle args = new Bundle();
        args.putSerializable(CHECK_BEAN, homeMenuEntity);
        ToiletBuildCheckFragment fragment = new ToiletBuildCheckFragment();
        fragment.setArguments(args);
        return fragment;
    }

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.fragment_build_check, container, false);
        unbinder = ButterKnife.bind(this, view);
        initView(inflater,view);
        initListener();
        return attachToSwipeBack(view);
    }

    /**
     * 初始化view
     *
     * @param inflater
     */
    private void initView(LayoutInflater inflater,View view) {
        EventBus.getDefault().register(this);
        toolbarTitle.setText("户厕改造检查");

        token_data = SPUtil.getString(Constants.KEY_TOKEN, "");

        btCheckTop = (Button) view.findViewById(R.id.bt_check_top);

        toolbarTitle.setVisibility(View.VISIBLE);
        //设置回键
        initToolbarBack(toolbar);
        //返回按钮
        toolbarBack.setVisibility(View.VISIBLE);


        toolbarIvMenu.setVisibility(View.VISIBLE);
        toolbarIvMenu.setImageResource(R.drawable.shaixuan);

        buildstateyearlist.add("下拉选择");
        buildstateyearlist.add("2020年之前");
        buildstateyearlist.add("2020年");


//=======================获取传递过来的值=================================
        Bundle arguments = getArguments();
        if (arguments != null) {
            homemenu_check = (HomeMenuEntity) arguments.getSerializable(CHECK_BEAN);
        }
//=======================获取传递过来的值=================================
        //添加刷新头和尾
        SinaRefreshView sinaHeader = new SinaRefreshView(_mActivity);
        sinaHeader.setArrowResource(R.drawable.arrow);
        sinaHeader.setTextColor(0xff745D5C);
        buildcheckTrefresh.setHeaderView(sinaHeader);

        LoadingView loadingView = new LoadingView(_mActivity);
        buildcheckTrefresh.setBottomView(loadingView);
        buildcheckTrefresh.setEnableLoadmore(false);

        //初始化index
        index = 0;
        buyItemList = new ArrayList<>();
        applyRvAdapter = new ToiletCheckRvAdapter(R.layout.item_toilet_check, buyItemList);
        buildcheckRv.setLayoutManager(new LinearLayoutManager(_mActivity));
        buildcheckRv.setAdapter(applyRvAdapter);
        applyRvAdapter.disableLoadMoreIfNotFullPage(buildcheckRv);

        emptyView = inflater.inflate(R.layout.view_empty, buildcheckRv, false);
        errorView = inflater.inflate(R.layout.view_error, buildcheckRv, false);
        footView = inflater.inflate(R.layout.view_foot, buildcheckRv, false);


    }

    /**
     * 监听
     */
    private void initListener() {

        check_RG.setOnCheckedChangeListener(this);
        checkRGLevel.setOnCheckedChangeListener(this);


        toolbarIvMenu.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

                if(buildcheckDrawlayout.isDrawerOpen(GravityCompat.END)){
                    buildcheckDrawlayout.closeDrawer(GravityCompat.END);
                }else{
                    buildcheckDrawlayout.openDrawer(GravityCompat.END);
                }

                if (viewchecklist == null) {
                    viewchecklist = new ArrayList<>();
                }

                //清空参数集合
                if (conditionmap != null) {
                    conditionmap.clear();
                }
                //改造类型value
                if (typelist == null) {
                    typelist = new ArrayList<>();
                }

            }
        });


        //---------applyRvAdapter条目点击---------------------------
        //applyRvAdapter条目点击事件-->点击整个条目,adapter中,子view不用addonclicklinstener
        applyRvAdapter.setOnItemClickListener(new BaseQuickAdapter.OnItemClickListener() {
            @Override
            public void onItemClick(BaseQuickAdapter adapter, View view, int position) {

               // Toast.makeText(_mActivity, "onItemClick" + position, Toast.LENGTH_SHORT).show();
                /*
                * 分检查,不合格 可进行编辑   合格,不可进行编辑
                * 是其他类型,就不进行跳转
                * */
                ArrayList<CheckItemEntity.DataBean> list = (ArrayList<CheckItemEntity.DataBean>) adapter.getData();
                CheckItemEntity.DataBean checkDataBean = list.get(position);
                if (checkDataBean != null) {
                    ////301 市  302 县  303 乡 304*
                    UserEntity userEntity = SPUtil.getBeanValue(Constants.KEY_USER, UserEntity.class);
                    if (userEntity != null) {

                        switch(userEntity.getOpt_level()){
                            case "301":
                            case "302":
                            case "303":
                                checkDataBean.setEdit(true);
                                EventBus.getDefault().post(new StartNewFragmentEvent(ToiletCheckDetialFragment.newInstance(checkDataBean)));
                                break;
                            case "304":
                                checkDataBean.setEdit(false);
                                EventBus.getDefault().post(new StartNewFragmentEvent(ToiletCheckDetialFragment.newInstance(checkDataBean)));
                                break;
                        }
//                        switch (checkDataBean.getJiancha_result_n()) {
//                            case "不合格":
//                            case "未检查":
//                                //可进行编辑
//                                if ("301".equals(userEntity.getOpt_level())
//                                        ||"302".equals(userEntity.getOpt_level())){
//                                    checkDataBean.setEdit(true);
//                                    EventBus.getDefault().post(new StartNewFragmentEvent(ToiletCheckDetialFragment.newInstance(checkDataBean)));
//                                }else{
//                                    checkDataBean.setEdit(false);
//                                    EventBus.getDefault().post(new StartNewFragmentEvent(ToiletCheckDetialFragment.newInstance(checkDataBean)));
//                                }
//
//                                break;
//                            case "合格":
//                                //不可进行编辑
//                                checkDataBean.setEdit(false);
//                                EventBus.getDefault().post(new StartNewFragmentEvent(ToiletCheckDetialFragment.newInstance(checkDataBean)));
//                                break;
//
//                            default:
//
//                                break;
//                        }

                    }
                }

            }
        });


        //---------列表的刷新---------------------------------------
        // buildcheckTrefresh
        buildcheckTrefresh.setOnRefreshListener(new RefreshListenerAdapter() {
            @Override
            public void onRefresh(TwinklingRefreshLayout refreshLayout) {
                super.onRefresh(refreshLayout);
                Log.e("显示", "refresh");

                new Handler().postDelayed(new Runnable() {
                    @Override
                    public void run() {
                        Log.e("显示", "refreshRun");
//                        mBuyAdapter.removeAllFooterView();

                        //清空参数集合
                        if (conditionmap != null) {
                            conditionmap.clear();
                        }

                        requestRefresh();
                    }
                }, 2000);
            }

            @Override
            public void onFinishRefresh() {
                super.onFinishRefresh();
                Log.e("显示", "Finishrefresh");
                applyRvAdapter.setEnableLoadMore(true);

            }
        });


        //预加载
        applyRvAdapter.setPreLoadNumber(Constant.PRE_SIZE);
        //设置动画
        applyRvAdapter.openLoadAnimation(BaseQuickAdapter.SCALEIN);


        //---------applyRvAdapter加载数据---------------------------
        //applyRvAdapter加载数据的监听
        applyRvAdapter.setOnLoadMoreListener(new BaseQuickAdapter.RequestLoadMoreListener() {
            @Override
            public void onLoadMoreRequested() {
                int currentSize = applyRvAdapter.getData().size();
                if (!TextUtils.isEmpty(mTotalSize)) {

                    int totalSize = Integer.parseInt(mTotalSize);
                    if (currentSize >= totalSize) {
                        applyRvAdapter.loadMoreEnd();
                    } else {
                        index++;


                        if (conditionmap!=null&&conditionmap.size()>0){
                            conditionLoadMore(conditionmap, index*pageSize, pageSize);

                        }else{
                            // loadMoreData(index, pageSize);
                            loadMoreData(index*pageSize, pageSize);
                        }

                    }
                }

            }
        }, buildcheckRv);

        //响应键盘回车
        etCheckHum.setOnEditorActionListener(new TextView.OnEditorActionListener() {
            @Override
            public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
                if (actionId == EditorInfo.IME_ACTION_UNSPECIFIED) {
                    hideSoftInput();
                    String huname = etCheckHum.getText().toString();
                    if (!TextUtils.isEmpty(huname)) {
                        conditionmap.put("b.huming@m", huname);
                    }

                    index = 0;
                    conditionLoadMore(conditionmap, index, pageSize);

                    etCheckHum.setText("");

                }

                return true;
            }
        });
    }


    /**
     * RadioGroup 点击监听
     *
     * @param radioGroup
     * @param i
     */
    @Override
    public void onCheckedChanged(RadioGroup radioGroup, @IdRes int i) {

        switch (i) {
            case R.id.check_rb_level_city://jiancha_level
                conditionmap.put("c.ope_level", "301");//市级
                break;
            case R.id.check_rb_level_conty:
                conditionmap.put("c.ope_level", "302");//县级
                break;
            case R.id.check_rb_pass:
                conditionmap.put("a.jiancha_result", "1");

                break;
            case R.id.check_rb_fail:
                conditionmap.put("a.jiancha_result", "0");

                break;
            case R.id.check_rb_un:
                conditionmap.put("a.jiancha_result", "-1");

                break;

            default:
                break;
        }

    }


    private boolean isSelectedAcceptOne, isSelectedAcceptTwo, isSelectedAcceptThree, isSelectedAcceptFour, isSelectedAcceptFive,
            isSelectedAcceptSix, isSelectedAcceptSeven, isSelectedAcceptEight, isSelectedAcceptPass, isSelectedAcceptFail;


    @OnClick({R.id.toolbar_back, R.id.bt_buildcheck_filter, R.id.check_tv_typeone,
            R.id.check_tv_typetwo, R.id.check_tv_typethree, R.id.check_tv_typefour,
            R.id.check_tv_typefive, R.id.check_tv_typesix, R.id.check_tv_typeseven,
            R.id.acceptcheck_tv_typeeight,R.id.bt_check_top,R.id.bt_check_huming,
            R.id.check_address_conty,R.id.check_address_town,R.id.check_address_village,
            R.id.check_reset, R.id.check_done,R.id.check_et_year_bg,R.id.check_et_year_end,
            R.id.toilet_check_statyear})//R.id.check_tv_pass, R.id.check_tv_fail,
    public void onViewClicked(View view) {
        switch (view.getId()) {
            //顶部户名查询
            case R.id.bt_check_huming:

                String huname = etCheckHum.getText().toString();
                if (!TextUtils.isEmpty(huname)) {
                    conditionmap.put("b.huming@m", huname);
                }

                index = 0;
                conditionLoadMore(conditionmap, index, pageSize);

                etCheckHum.setText("");


                break;
            //返回顶部
            case R.id.bt_check_top:

                buildcheckRv.smoothScrollToPosition(0);

                break;


            //筛选
            case R.id.bt_buildcheck_filter:
//                buildcheckDrawlayout.openDrawer(Gravity.END);
//                if (viewchecklist == null) {
//                    viewchecklist = new ArrayList<>();
//                }
//
//                //清空参数集合
//                if (conditionmap != null) {
//                    conditionmap.clear();
//                }
//
//                /*
//                * 设置map集合对应的字段
//                * 1.所属地:(a.area_id@m,"") 户名:(a.huming@m,"")  身份证号:(a.cert_no@m,"")
//                *
//                * */
//
//                //改造类型value
//                if (typelist == null) {
//                    typelist = new ArrayList<>();
//                }


                break;

            //县乡村数据
            case R.id.check_address_conty:

                checkcontyPW = new ListPopupWindow(_mActivity);
                setPopuDataList(view, checkcontyPW, contylist);
                setPopuClickListenerList(new ContyPopuListener() {
                    @Override
                    public void show(CountyEntity Centity, String text) {
                        checkAddressConty.setText(Centity.getText());
                        //showLoadingDialog("正在加载乡镇数据");
                        SPUtil.putString(Constants.CHECK_CONTY_LEVEL, "xian");
                        SPUtil.putString(Constants.CHECK_CONTY_ID, Centity.getValue());
                        getTownList(Centity.getValue());
                    }
                });
                break;
            case R.id.check_address_town:

                String conty_address = checkAddressConty.getText().toString().trim();
                if (TextUtils.isEmpty(conty_address) || "(区)县".equals(conty_address)) {
                    showShortToast("请先选择县级单位");
                    return;
                } else {
                    try {
                        if (twonlist != null && twonlist.size() > 0) {
                            checktwonPW = new ListPopupWindow(_mActivity);
                            setPopuDataList(view, checktwonPW, twonlist);
                            setPopuClickListenerList(new ContyPopuListener() {
                                @Override
                                public void show(CountyEntity Centity, String text) {
                                    checkAddressTown.setText(Centity.getText());
                                    SPUtil.putString(Constants.CHECK_CONTY_LEVEL,"xiang");
                                    SPUtil.putString(Constants.CHECK_CONTY_ID,Centity.getValue());
                                    //showLoadingDialog("正在加载村级数据");
                                    getVillageList(Centity.getValue());

                                }
                            });
                        }
                    } catch (Exception e) {
                        LogUtils.i("list为null", "乡级列表onViewClicked: " + e.toString());
                    }

                }


                break;
            case R.id.check_address_village:



                String town_address = checkAddressTown.getText().toString().trim();
                if (TextUtils.isEmpty(town_address) || "乡".equals(town_address)) {
                    showShortToast("请先选择乡级单位");
                    return;
                } else {

                    try {
                        if (villagelist != null && villagelist.size() > 0) {
                            ListPopupWindow checkvillagePW = new ListPopupWindow(_mActivity);
                            setPopuDataList(view, checkvillagePW, villagelist);
                            setPopuClickListenerList(new ContyPopuListener() {
                                @Override
                                public void show(CountyEntity Centity, String text) {
                                    checkAddressVillage.setText(Centity.getText());
                                    SPUtil.putString(Constants.CHECK_CONTY_LEVEL,"cun");
                                    SPUtil.putString(Constants.CHECK_CONTY_ID,Centity.getValue());

                                }
                            });
                        }
                    } catch (Exception e) {
                        LogUtils.i("list为null", "村级列表onViewClicked: " + e.toString());

                    }


                }


                break;


            //8种类型
            case R.id.check_tv_typeone:
                if (!isSelectedAcceptOne) {
                    view.setSelected(true);
                    typelist.add("208");
                } else {
                    view.setSelected(false);
                    if (typelist.contains("208")) {
                        typelist.remove("208");
                    }
                }
                isSelectedAcceptOne = !isSelectedAcceptOne;
                if (view.isSelected()) {
                    viewchecklist.add(view);
                }
                break;
            case R.id.check_tv_typetwo:
                if (!isSelectedAcceptTwo) {
                    view.setSelected(true);
                    typelist.add("206");
                } else {
                    view.setSelected(false);
                    if (typelist.contains("206")) {
                        typelist.remove("206");
                    }
                }
                isSelectedAcceptTwo = !isSelectedAcceptTwo;
                if (view.isSelected()) {
                    viewchecklist.add(view);
                }
                break;
            case R.id.check_tv_typethree:
                if (!isSelectedAcceptThree) {
                    view.setSelected(true);
                    typelist.add("205");
                } else {
                    view.setSelected(false);
                    if (typelist.contains("205")) {
                        typelist.remove("205");
                    }
                }
                isSelectedAcceptThree = !isSelectedAcceptThree;
                if (view.isSelected()) {
                    viewchecklist.add(view);
                }
                break;
            case R.id.check_tv_typefour:
                if (!isSelectedAcceptFour) {
                    view.setSelected(true);
                    typelist.add("207");
                } else {
                    view.setSelected(false);
                    if (typelist.contains("207")) {
                        typelist.remove("207");
                    }
                }
                isSelectedAcceptFour = !isSelectedAcceptFour;
                if (view.isSelected()) {
                    viewchecklist.add(view);
                }
                break;
            case R.id.check_tv_typefive:
                if (!isSelectedAcceptFive) {
                    view.setSelected(true);
                    typelist.add("202");
                } else {
                    view.setSelected(false);
                    if (typelist.contains("202")) {
                        typelist.remove("202");
                    }
                }
                isSelectedAcceptFive = !isSelectedAcceptFive;
                if (view.isSelected()) {
                    viewchecklist.add(view);
                }
                break;
            case R.id.check_tv_typesix:
                if (!isSelectedAcceptSix) {
                    view.setSelected(true);
                    typelist.add("203");
                } else {
                    view.setSelected(false);
                    if (typelist.contains("203")) {
                        typelist.remove("203");
                    }
                }
                isSelectedAcceptSix = !isSelectedAcceptSix;
                if (view.isSelected()) {
                    viewchecklist.add(view);
                }
                break;
            case R.id.check_tv_typeseven:
                if (!isSelectedAcceptSeven) {
                    view.setSelected(true);
                    typelist.add("204");
                } else {
                    view.setSelected(false);
                    if (typelist.contains("204")) {
                        typelist.remove("204");
                    }
                }
                isSelectedAcceptSeven = !isSelectedAcceptSeven;
                if (view.isSelected()) {
                    viewchecklist.add(view);
                }
                break;
            case R.id.acceptcheck_tv_typeeight:
                if (!isSelectedAcceptEight) {
                    view.setSelected(true);
                    typelist.add("201");

                } else {
                    view.setSelected(false);
                    if (typelist.contains("201")) {
                        typelist.remove("201");
                    }
                }
                isSelectedAcceptEight = !isSelectedAcceptEight;
                if (view.isSelected()) {
                    viewchecklist.add(view);
                }
                break;
            //pass 和  fail
//            case R.id.check_tv_pass:
//                break;
//            case R.id.check_tv_fail:
//                break;

            //开始抽检时间检索
            case R.id.check_et_year_bg:
                TimePickerView.Type type = TimePickerView.Type.YEAR_MONTH_DAY;
                TimePickerView pvTime = new TimePickerView(_mActivity, type);
                String format = "yyyy-MM-dd";
                UtilPop.alertTimerPickerEh(getActivity(), pvTime, format, new UtilPop.TimerPickerCallBack() {
                    @Override
                    public void onTimeSelect(String date) {
                        String nowTime = getNowTime();
                        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
                        TimeUtils.getIntervalTime2(date, nowTime, ConstUtils.TimeUnit.DAY, sdf);
                        if (TimeUtils.getTypeValue() == 1) {
                            showShortToast("选择时间不能晚于当前时间");
                        } else {

                            checkEtYearBg.setText(date);

                            conditionmap.put("a.opt_time@db",date);


                        }
                    }
                });


                break;
            //结束抽检时间检索
            case R.id.check_et_year_end:
                final String bg_time = checkEtYearBg.getText().toString().trim();

                if(TextUtils.isEmpty(bg_time)||bg_time==null){
                    showAlertOnlyPos(_mActivity,"起始时间","请先选择起始时间");
                    return;
                }

                TimePickerView.Type type1 = TimePickerView.Type.YEAR_MONTH_DAY;
                TimePickerView pvTime1 = new TimePickerView(_mActivity, type1);
                String format1 = "yyyy-MM-dd";
                UtilPop.alertTimerPickerEh(getActivity(), pvTime1, format1, new UtilPop.TimerPickerCallBack() {
                    @Override
                    public void onTimeSelect(String date) {
                        String nowTime = getNowTime();
                        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
                        TimeUtils.getIntervalTime3(date,bg_time, nowTime, ConstUtils.TimeUnit.DAY, sdf);


                        if (TimeUtils.getTypeValue() == 0) {
                            showShortToast("选择时间不能晚于起始时间");
                        } else if(TimeUtils.getTypeValue() == 2){
                            showShortToast("选择时间不能晚于当前时间");
                        }else{
                            checkEtYearEnd.setText(date);
                            conditionmap.put("a.opt_time@de",date);
                        }
                    }
                });


                break;

            //任务年份
            case R.id.toilet_check_statyear:

                buildstatyearPopupWindow = new ListPopupWindow(_mActivity);
                setPopuData(view, buildstatyearPopupWindow, buildstateyearlist);
                setPopuClickListener(new PopuClickListener() {
                    @Override
                    public void show(String mess) {
                        toiletCheckStatyear.setText(mess);
                        //添加到参数中
                        if (!"下拉选择".equals(mess)) {
                            conditionmap.put("stat_year_n", mess);
                            if ("2020年之前".equals(mess)) {
                                conditionmap.put("stat_year", "2019");
                            } else if ("2020年".equals(mess)) {
                                conditionmap.put("stat_year", "2020");
                            }
                        }

                    }
                });

                break;

            case R.id.check_reset:

                for (View v : viewchecklist) {
                    v.setSelected(false);
                }
                resetbooleanacceptstate();
                viewchecklist.clear();

                check_RG.clearCheck();
                checkRGLevel.clearCheck();

                //清空参数集合
                if (conditionmap != null) {
                    conditionmap.clear();
                    checkEtYearBg.setText("");
                    checkEtYearEnd.setText("");
                }

                checkAddressConty.setText("县");
                checkAddressTown.setText("乡");
                checkAddressVillage.setText("村");

                checkEtNumber.setText("");
                checkEtNumber.setHint("请输入户编号");
                checkEtYearBg.setText("");
                checkEtYearBg.setHint("请选择起始日期");
                checkEtYearEnd.setText("");
                checkEtYearEnd.setHint("请选择结束日期");
                toiletCheckStatyear.setText("下拉选择");

                break;
            //提交
            case R.id.check_done:

                showLoadingDialog();

                //将参数添加到map集合中,添加时进行校验,3个都是选填
//                String address = checkEtAddress.getText().toString();
//                if (!TextUtils.isEmpty(address)) {
//                    conditionmap.put("a.area_id@m", address);
//                }

                //辖区单位
                String addressConty = checkAddressConty.getText().toString();
                String addressTown = checkAddressTown.getText().toString();
                String addressvillage = checkAddressVillage.getText().toString();

                if (!"县".equals(addressConty)|!"乡".equals(addressTown)|!"村".equals(addressvillage)){
                    String conty_level = SPUtil.getString(Constants.CHECK_CONTY_LEVEL, "");
                    if ("xian".equals(conty_level)){
                        if (conditionmap.containsKey("a.xiang_area_id")){
                            conditionmap.remove("a.xiang_area_id");
                        }
                        if (conditionmap.containsKey("b.area_id")){
                            conditionmap.remove("b.area_id");
                        }
                        conditionmap.put("a.xian_area_id", SPUtil.getString(Constants.CHECK_CONTY_ID,""));
                    }else if ("xiang".equals(conty_level)){
                        if (conditionmap.containsKey("a.xian_area_id")){
                            conditionmap.remove("a.xian_area_id");
                        }
                        if (conditionmap.containsKey("b.area_id")){
                            conditionmap.remove("b.area_id");
                        }
                        conditionmap.put("a.xiang_area_id", SPUtil.getString(Constants.CHECK_CONTY_ID,""));
                    }else if ("cun".equals(conty_level)){
                        if (conditionmap.containsKey("a.xian_area_id")){
                            conditionmap.remove("a.xian_area_id");
                        }
                        if (conditionmap.containsKey("a.xiang_area_id")){
                            conditionmap.remove("a.xiang_area_id");
                        }
                        conditionmap.put("b.area_id", SPUtil.getString(Constants.CHECK_CONTY_ID,""));
                    }
                }

//                String huname = checkEtDoorname.getText().toString();
//                if (!TextUtils.isEmpty(huname)) {
//                    conditionmap.put("a.huming@m", huname);
//                }
                String hunumber = checkEtNumber.getText().toString();
                if (!TextUtils.isEmpty(hunumber)) {
                    conditionmap.put("b.hubianhao@m", hunumber);
                }
                //去掉身份证号
//                String idnum = checkEtIidnumber.getText().toString();
//                if (RegexUtils.isIDCard18(idnum)) {
//                    conditionmap.put("a.cert_no@m", idnum);
//                }


                //关闭侧滑放在return语句之后
                buildcheckDrawlayout.closeDrawer(GravityCompat.END);

                for (View v : viewchecklist) {
                    v.setSelected(false);
                }
                resetbooleanacceptstate();
                viewchecklist.clear();
                check_RG.clearCheck();
                checkRGLevel.clearCheck();

//=========================改造类型====================================================

                buildtypeValue();

//=========================根据map集合里的参数请求筛选数据=================================


                index = 0;

                conditionLoadMore(conditionmap, index, pageSize);

                syso(conditionmap);

                //置为空
                checkEtAddress.setText("");
                checkEtDoorname.setText("");
                checkEtNumber.setText("");
                checkEtIidnumber.setText("");

                checkAddressConty.setText("县");
                checkAddressTown.setText("乡");
                checkAddressVillage.setText("村");
                toiletCheckStatyear.setText("下拉选择");

                checkEtYearBg.setText("");
                checkEtYearEnd.setText("");

                //清空集合参数----->条件查询时,加载更多不能在关闭侧滑时清空--->这里得注释掉
                //conditionmap.clear();

                cancelLoadingDialog();

                break;
        }
    }

    /**
     * 得到当前时间
     */
    private String getNowTime() {
        SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
        Date curDate = new Date(System.currentTimeMillis());//获取当前时间
        String str = formatter.format(curDate);
        return str;
    }


    //模拟输出测验
    private void syso(Map<String, String> conditionmap) {
        Set<Map.Entry<String, String>> entrySet = conditionmap.entrySet();
        Iterator<Map.Entry<String, String>> iterator = entrySet.iterator();
        while (iterator.hasNext()) {
            Map.Entry<String, String> me = iterator.next();
            String key = me.getKey();
            String value = me.getValue();

            LogUtils.i("检查conditionmap", key + ":" + value);

        }

    }

    /**
     * 重置状态
     */
    private void resetbooleanacceptstate() {
        isSelectedAcceptOne = false;
        isSelectedAcceptTwo = false;
        isSelectedAcceptThree = false;
        isSelectedAcceptFour = false;
        isSelectedAcceptFive = false;
        isSelectedAcceptSix = false;
        isSelectedAcceptSeven = false;
        isSelectedAcceptEight = false;
        isSelectedAcceptPass = false;
        isSelectedAcceptFail = false;

    }


    /**
     * 改造类型 单选或者双选
     */
    private void buildtypeValue() {
        //conditionmap
        StringBuilder statue_value = new StringBuilder();
        if (typelist != null && typelist.size() > 0) {

            if (typelist.size() > 1) {
                //多个,多选,需要用","拼接value
                for (int i = 0; i < typelist.size(); i++) {
                    statue_value.append(typelist.get(i) + ",");
                }
            } else {
                //只有一个,单选,不用拼接value
                statue_value.append(typelist.get(0));
            }

            String sv_temp = statue_value.toString().trim();
            if (sv_temp.endsWith(",")) {
                LogUtils.i("statuevalue", "if: " + sv_temp);
                sv_temp = sv_temp.substring(0, statue_value.length() - 1);
                LogUtils.i("statuevalue", "if: " + sv_temp);

            }

            conditionmap.put("a.gaizao_type@i", sv_temp);
        }


        typelist.clear();
    }

//====================listpopuwindow  县 村=======================================


    /**
     * 显示listpopuwindow,并使用回调,显示数据
     *
     * @param view
     * @param mPopupWindow
     * @param datalists
     */

    private void setPopuDataList(View view, final ListPopupWindow mPopupWindow, final List<CountyEntity> datalists) {

        //清空集合,添加数据
        namelist.clear();
        for (CountyEntity ce : datalists) {
            namelist.add(ce.getText());
        }
        ArrayAdapter<String> adapter = new ArrayAdapter<>(_mActivity, android.R.layout.simple_list_item_1, namelist);
        mPopupWindow.setAdapter(adapter);

        //弹出的位置  弹出锚点
        //mPopupWindow.setAnchorView(view);
        mPopupWindow.setAnchorView(allSlidingLicateCheck);

        //mPopupWindow.setVerticalOffset(ConvertUtils.dp2px(_mActivity, 12));

//        mPopupWindow
        //设置宽高
        mPopupWindow.setHeight(ViewGroup.LayoutParams.WRAP_CONTENT);
//        mPopupWindow.setWidth(ViewGroup.LayoutParams.MATCH_PARENT);
        mPopupWindow.setWidth(ViewGroup.LayoutParams.WRAP_CONTENT);


        mPopupWindow.setModal(true);//设置模态框，设置为true响应物理键
        //设置条目点击事件
        mPopupWindow.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                //使用回调,显示数据
                if (popuClickListenerList != null) {
                    popuClickListenerList.show(datalists.get(position), datalists.get(position).getText());
                }
                mPopupWindow.dismiss();
            }
        });
        mPopupWindow.show();


    }

    public ContyPopuListener popuClickListenerList;

    public void setPopuClickListenerList(ContyPopuListener popuClickListenerList) {
        this.popuClickListenerList = popuClickListenerList;
    }
//--------------------------------------------------------------------------------------







    /**
     * eventbus 页面跳转验证页面,事件接受
     *
     * @param center
     */
    @Subscribe
    public void onEventReceive(EventCenter center) {

        if (center.getEventCode() == EventConstant.UPLOAD_BUY_MODIFY) {
            //提交成功
            LogUtils.e("显示", "刷新");
            new Handler() {
            }.postDelayed(new Runnable() {
                @Override
                public void run() {
                    // requestRefresh();
                    Toast.makeText(_mActivity, "跳转到验证页面", Toast.LENGTH_SHORT).show();
                }
            }, 500);
        }
    }


    /**
     * eventbus 页面跳转,事件接受
     *
     * @param messageEvent
     */
    @Subscribe
    public void onEventReceive(MessageEvent messageEvent) {

        if ("363".equals(messageEvent.getMessage())) {
            //提交成功
            LogUtils.e("显示", "刷新");
            new Handler() {
            }.postDelayed(new Runnable() {
                @Override
                public void run() {
                    requestRefresh();
                }
            }, 500);
        }
    }

    /**
     * 页面加载动画结束就调用  loadMoreData(index, pageSize);
     * 所以  将两个方法紧挨着
     *
     * @param savedInstanceState
     */
    @Override
    public void onEnterAnimationEnd(Bundle savedInstanceState) {
        super.onEnterAnimationEnd(savedInstanceState);
        //添加家在逻辑
        Log.e("显示", "指示enter " + index);


        loadMoreData(index, pageSize);

        //获取县乡村数据
        getLevelData();

    }


    /**
     * 获取县乡村数据
     */
    private void getLevelData() {
        //获取县,乡,村级列表数据
        //获取个人信息
        UserEntity userEntity = SPUtil.getBeanValue(Constants.KEY_USER, UserEntity.class);
        if (userEntity != null) {
            //获取县级列表
            getContyList(userEntity);


        }

    }


    //县级列表
    private List<CountyEntity> contylist = null;
    //乡级列表
    private List<CountyEntity> twonlist = null;
    //村级列表
    private List<CountyEntity> villagelist = null;

    private void getContyList(UserEntity userEntity) {
        //需要拼接
        // String addnew_url = HttpApis.addnew_info+userEntity.getArea_id()+"/"+userEntity.getArea_level();
        String addnew_url = HttpApis.addnew_info + userEntity.getArea_id() + "/" + "3";


       // showLoadingDialog("正在加载县级数据");
        if (cavRequest == null) {
            cavRequest = new ContyRequest();
        }
        HashMap<String, String> map = new HashMap<>();
        map.put("token",token_data);

        LogUtils.i("乡级列表", "url: " + addnew_url);
        HttpUtils.requestGet(_mActivity, addnew_url,map, cavRequest);
    }

    private void getTownList(String conty_id) {
        String addnew_url = HttpApis.addnew_info + conty_id + "/" + "4";


        if (twonRequest == null) {
            twonRequest = new TwonRequest();
        }
        HashMap<String, String> map = new HashMap<>();
        map.put("token",token_data);

        LogUtils.i("县级列表", "url: " + addnew_url);
        HttpUtils.requestGet(_mActivity, addnew_url,map, twonRequest);

    }

    private void getVillageList(String teon_id) {
        String addnew_url = HttpApis.addnew_info + teon_id + "/" + "5";

        if (villageRequest == null) {
            villageRequest = new VillageRequest();
        }

        HashMap<String, String> map = new HashMap<>();
        map.put("token",token_data);
        LogUtils.i("村级列表", "url: " + addnew_url);
        HttpUtils.requestGet(_mActivity, addnew_url,map, villageRequest);
    }


    private class ContyRequest extends Request {
        @Override
        public void success(String jsonStr) {
            super.success(jsonStr);

            LogUtils.i("乡级列表", "success: " + jsonStr);

            Type type = new TypeToken<ArrayList<CountyEntity>>() {
            }.getType();

            contylist = JsonUtil.json2Collection(jsonStr, type);

           // cancelLoadingDialog();
        }

        @Override
        public void error(String error) {
            super.error(error);
            LogUtils.i("乡级列表", "error: " + error);

            //cancelLoadingDialog();
        }
    }

    private class TwonRequest extends Request {
        @Override
        public void success(String jsonStr) {
            super.success(jsonStr);

            LogUtils.i("县级列表", "success: " + jsonStr);

            Type type = new TypeToken<ArrayList<CountyEntity>>() {
            }.getType();

            twonlist = JsonUtil.json2Collection(jsonStr, type);

           // cancelLoadingDialog();
        }

        @Override
        public void error(String error) {
            super.error(error);
            LogUtils.i("县级列表", "error: " + error);

            //cancelLoadingDialog();
        }
    }

    private class VillageRequest extends Request {
        @Override
        public void success(String jsonStr) {
            super.success(jsonStr);

            LogUtils.i("村级列表", "success: " + jsonStr);

            Type type = new TypeToken<ArrayList<CountyEntity>>() {
            }.getType();

            villagelist = JsonUtil.json2Collection(jsonStr, type);

           // cancelLoadingDialog();
        }

        @Override
        public void error(String error) {
            super.error(error);
            LogUtils.i("村级列表", "error: " + error);

            //cancelLoadingDialog();
        }
    }



    /**
     * 页面条转过来就刷新数据
     */
    private void requestRefresh() {
        Log.e("显示", "指示refresh " + index);
        applyRvAdapter.setEnableLoadMore(false);
        buyItemList.clear();
        applyRvAdapter.setNewData(buyItemList);

        if (buildcheckTrefresh != null) {
            buildcheckTrefresh.finishRefreshing();
        }
        index = 0;
        loadMoreData(index, pageSize);
    }

    /**
     * 加载数据
     *
     * @param index    页数
     * @param pageSize
     */
    private void loadMoreData(int index, int pageSize) {

        if (index == 0) {
            showLoadingDialog();
        }
        LogUtils.i("显示", "指示loadmore " + index);

        btCheckTop.setText("顶部");

        String mCheck_url = HttpApis.checkDetial_item;

        LogUtils.i("checkitemResault", mCheck_url);
        if (checkitemRequest == null) {
            checkitemRequest = new CheckItemRequest();
        }
        Map<String, String> map = new HashMap<>();
        map.put("iud", homemenu_check.getIud());
        map.put("start", String.valueOf(index));
        map.put("pagesize", String.valueOf(pageSize));
        map.put("token",token_data);
        HttpUtils.requestGet(_mActivity, mCheck_url, map, checkitemRequest);
    }

    /**
     * 条件查询加载数据
     *
     * @param index    页数
     * @param pageSize
     */
    private void conditionLoadMore(Map<String, String> conditionmap, int index, int pageSize) {

        if (index == 0) {
            showLoadingDialog();
        }
        LogUtils.i("显示", "指示loadmore " + index);

        String mCheck_url = HttpApis.checkDetial_item;


        LogUtils.i("checkitemResault", mCheck_url);
        if (checkitemRequest == null) {
            checkitemRequest = new CheckItemRequest();
        }
        Map<String, String> map = new HashMap<>();
        map.put("iud", homemenu_check.getIud());
        map.put("start", String.valueOf(index));
        map.put("pagesize", String.valueOf(pageSize));
        map.put("token",token_data);

        if (conditionmap != null && conditionmap.size() > 0) {
            map.putAll(conditionmap);
        }
        HttpUtils.requestGet(_mActivity, mCheck_url, map, checkitemRequest);
    }


    private class CheckItemRequest extends Request {
        @Override
        public void success(String jsonStr) {
            super.success(jsonStr);

            LogUtils.i("checkitemResault", jsonStr);

            CheckItemEntity CheckItemBean = GsonTools.changeGsonToBean(jsonStr, CheckItemEntity.class);

            //将数据解析出来
            processData(CheckItemBean);
            applyRvAdapter.loadMoreComplete(); //加载完

            if (index == 0) {
                cancelLoadingDialog();
            }

        }

        @Override
        public void error(String error) {
            super.error(error);
            LogUtils.e("checkitemResault", error);
            if (!NetworkUtils.isConnected(_mActivity)) {
                applyRvAdapter.setEmptyView(errorView);
            } else {
                applyRvAdapter.setEmptyView(emptyView);
                applyRvAdapter.loadMoreFail();
            }

            if (index == 0) {
                cancelLoadingDialog();
            }
        }
    }

    //临时存放此处
    private String mTotalSize;

    /**
     * 讲解析出来的数据,进行加载
     *
     * @param CheckitemEntity
     */
    private void processData(CheckItemEntity CheckitemEntity) {
        LogUtils.e("显示", "指示process " + index);

        if (CheckitemEntity != null) {
            mTotalSize = CheckitemEntity.getRecordsTotal();

            if(conditionmap!=null&&conditionmap.size()>0){
                //btCheckTop.setText(mTotalSize);
                tvCheckHuceCount.setText(mTotalSize+"户");
            }
            tvCheckHuceCount.setText(mTotalSize+"户");
            if (Integer.parseInt(mTotalSize) > 0) {
                if (index == 0) {
                    //设置新数据
                    applyRvAdapter.setNewData(CheckitemEntity.getData());
                } else {
                    applyRvAdapter.addData(CheckitemEntity.getData());
                }
            } else {
                applyRvAdapter.setNewData(null);
                applyRvAdapter.setEmptyView(emptyView);
            }
            LogUtils.e("显示", "数据u" + applyRvAdapter.getData().size());
        } else {
            applyRvAdapter.setEmptyView(emptyView);
        }

    }


    //-------------设置popu传值接口-----------------------------------------------------------

    private void setPopuData(View view, final ListPopupWindow mPopupWindow, final List<String> datalist) {
        ArrayAdapter<String> adapter = new ArrayAdapter<>(_mActivity, android.R.layout.simple_list_item_1, datalist);
        mPopupWindow.setAdapter(adapter);
        //弹出的位置  弹出锚点
        mPopupWindow.setAnchorView(view);
        //设置宽高
        mPopupWindow.setHeight(ViewGroup.LayoutParams.WRAP_CONTENT);
        mPopupWindow.setWidth(ViewGroup.LayoutParams.WRAP_CONTENT);

        mPopupWindow.setModal(true);//设置模态框，设置为true响应物理键
        //设置条目点击事件
        mPopupWindow.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                //使用回调,显示数据
                if (popuClickListener != null) {
                    popuClickListener.show("" + datalist.get(position));
                }
                mPopupWindow.dismiss();
            }
        });
        mPopupWindow.show();
    }


    public PopuClickListener popuClickListener;

    public void setPopuClickListener(PopuClickListener popuClickListener) {
        this.popuClickListener = popuClickListener;
    }
//--------------------------------------------------------------------------------------


    @Override
    public boolean onBackPressedSupport() {

        if (buildcheckDrawlayout.isDrawerOpen(GravityCompat.END)) {
            buildcheckDrawlayout.closeDrawer(GravityCompat.END);
            return true;
        } else {
            return false;
        }

    }

    @Override
    public void onPause() {
        super.onPause();
        LogUtils.i("hashqi", "onPause: ");
        OkHttpUtils.getInstance().cancelTag(this);
        cancelLoadingDialog();
    }


    @Override
    public void onDestroyView() {
        super.onDestroyView();
        unbinder.unbind();
        EventBus.getDefault().unregister(this);
        OkHttpUtils.getInstance().cancelTag(this);
        cancelLoadingDialog();
    }


}
